<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/jquery-3.6.0.min.js"></script>
		<script  type="text/javascript">
		$(function(){
			$("#btn").click(function(){
				if(name==""||pwd==""){
					$("#msg").html("账号或者密码不能为空");
				}else{
				//获取账号。。。密码
				var name=$("#name").val()
				var pwd=$("#pwd").val()
				$.ajax({
				url: "http://10.64.149.30:8080/practice1/customerServlet",
				method:"post",
				data:{"method":"login","c_name":name,"c_pass":pwd},
				dataType:"json",//预判断
				success:function(result){
					//$("#msg").html(result.msg);
					//console.log(result.code);
				if(result.code==200){
						//登录成功 获取token
						// 	$("#msg").html(result.token);
						window.location.href="index.html";
					}else if(result.code==500){
					// 	//登录失败 获取msg
					// 	$("#msg").html(result.msg);
					 }
					},	
			})}
			});
		});
		</script>
	</head>
	<body>
		<span id="msg"></span>
		<form action="" method="post" onsubmit="return false">
			<input type="text" name="username" id="name"/>账号<br/>
			<input type="password" name="password"id="pwd">密码<br/>
			<button id="btn">提交</button>
		</form>
	</body>
</html>
